package com.mashibing.tank.Strategy;

import com.mashibing.tank.pojo.Bullet;
import com.mashibing.tank.pojo.Dir;
import com.mashibing.tank.pojo.Tank;

/**
 * @ClassName FourDirFireStrategy
 * @Description 向四个方向开火
 * @Author zhangjunhao
 * @DATE 2023/8/29 10:13
 */
public class FourDirFireStrategy implements FireStrategy {
    @Override
    public void fire(Tank tank) {

        //子弹打出的位置
        int bX = tank.getX() + tank.getWIDTH() / 2 - Bullet.getWIDTH() / 2;
        int bY = tank.getY() + tank.getHEIGHT() / 2 - Bullet.getHEIGHT() / 2;

        //公平模式-1
        tank.getTankFrame().gameFactory.createBullet(bX, bY, tank.getDir(), tank.getGroup(), tank.getTankFrame());


       /* //向四个窗口发射子弹 不公平模式-2
        Dir[] dirs = Dir.values();
        for (Dir dir : dirs) {
            tank.getTankFrame().gameFactory.createBullet(bX, bY, dir, tank.getGroup(), tank.getTankFrame());
        }*/


    }
}
